package cn.crm.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import cn.crm.bean.CustomerInfo;
import cn.crm.dao.CustomerInfoDao;

@Repository("customerInfoDao")
public class CustomerInfoDaoImpl extends HibernateDaoSupport implements
		CustomerInfoDao {
	@Override
	public List<CustomerInfo> getAll() {
		List<CustomerInfo> list=super.getHibernateTemplate().find("from CustomerInfo");
		return list.size()>0?list:null;
	}

	@Override
	public CustomerInfo getCustomerInfoById(Integer id) {
		List<CustomerInfo> list=super.getHibernateTemplate().find("from CustomerInfo where cinfoCid=?",id);
		return list.size()>0?list.get(0):null;
	}

	@Override
	public Object save(CustomerInfo customerInfo) {
		return super.getHibernateTemplate().save(customerInfo);
	}

	@Override
	public void update(CustomerInfo customerInfo) {
		super.getHibernateTemplate().update(customerInfo);

	}

	@Override
	public void delete(CustomerInfo customerInfo) {
		super.getHibernateTemplate().delete(customerInfo);
	}

	@Override
	public Object saveOrUpdate(CustomerInfo customerInfo) {
		super.getHibernateTemplate().saveOrUpdate(customerInfo);
		return null;
	}
}
